package ui.panels.menus;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import ui.flowManager.expirimentProperties.ExperimentProperties;
import ui.panels.primary.adaptiveAgents.AdaptiveAgentsPanel;

public class AdaptiveAgentsPopUpMenu extends JPopupMenu {

    private JMenuItem 				deleteItem = null;
    private ExperimentProperties	props = null;
    private int						playerNumber = 0;  
    private AdaptiveAgentsPanel 	adaptiveAgentsPanel = null;
    
    public AdaptiveAgentsPopUpMenu(int playerNumber, AdaptiveAgentsPanel panel,
    		ExperimentProperties props){
    	this.playerNumber = playerNumber;
    	this.adaptiveAgentsPanel = panel;
    	this.props = props;
    	
    	deleteItem = new JMenuItem("Delete");
        add(deleteItem);      
        setListeners();
    }
    
    /**
     * Set the listeners for:
     * 			1. Delete
     */
    private void setListeners()
    {
    	deleteItem.addActionListener(new MenuActionListener());
    }
    
    
    class MenuActionListener implements ActionListener {

		public void actionPerformed(ActionEvent event) {
			//case was delete
			if(event.getSource() == deleteItem){
				//update the UI
				adaptiveAgentsPanel.setTheListUI(playerNumber, props);		
				//remove from props
				adaptiveAgentsPanel.removeFromProperties(playerNumber, props);
			}
		}
		

    }
    
}
